package com.cheyun.netsalev3.workers

import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import com.cheyun.netsalev3.bean.dm.DmSearch
import com.cheyun.netsalev3.dao.AppDatabase

/**
 * 后台线程
 */
class DmSearchDatabaseWorker(context: Context, workerParams: WorkerParameters) : Worker(context, workerParams) {
    override fun doWork(): Result {
        val database = AppDatabase.getInstance(applicationContext)
        var key = ""
        inputData.getString("key")?.apply {
            key = this
        }
        database.getDmSearchDao().insertSearch(DmSearch(key))
        return Result.success()
    }
}